package study.async.springboot.controller;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.eggs.result.Result;
import study.eggs.result.Results;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Slf4j
@RestController
public class _1_ExecutorController {

    private ExecutorService pool = Executors.newFixedThreadPool(10);

    @RequestMapping("/executor")
    public Result executor() {
        log.info(">>>>>> 11231231");
        pool.execute(() -> {
            try {
                ThreadUtil.sleep(3000);
                log.info(">>>>>> adsfasdfsd");
            } catch (Exception ex) {
            }
        });
        return Results.ok();
    }
}
